﻿@using UsedBookTradeSystem.Models.Entity;
@{
    ViewData["Title"] = "Index";
    Layout = "~/Views/Shared/_BackLayout.cshtml";
    int index = 0;
}

<div class="container-fluid flex-grow-1 container-p-y">
    <h4 class="font-weight-bold py-3 mb-0">书籍管理</h4>

    <div class="card">
        <div class="card-header">
            <p style="display:inline;vertical-align:middle">书籍列表</p>
            @Html.ActionLink("添加", "Add", new { }, new { @class = "btn btn-success deleteBtn", @style = "float:right" })
        </div>
        <table class="table card-table">
            <thead class="thead-light">
                <tr>
                    <th>#</th>
                    <th>书籍名称</th>
                    <th>书籍分类</th>
                    <th>作者</th>
                    <th>出版社</th>
                    <th>价格</th>
                    <th>库存</th>
                    <th>封面</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (BookInfo item in ViewBag.BookList)
                {
                    index++;
                    <tr>
                        <td scope="row" style="vertical-align:middle">@index</td>
                        <td style="vertical-align:middle">@item.BookName</td>
                        <td style="vertical-align:middle">@item.Category.CategoryName</td>
                        <td style="vertical-align:middle">@item.Author</td>
                        <td style="vertical-align:middle">@item.Press</td>
                        <td style="vertical-align:middle">@item.Price</td>
                        <td style="vertical-align:middle">@item.Inventory</td>
                        <td style="vertical-align:middle"><img width="100px" height="100px" src="@item.Picture" /></td>
                        <td style="vertical-align:middle">
                            @Html.ActionLink("编辑", "Edit", new { id = item.Id }, new { @class = "btn btn-success deleteBtn" })
                            @Html.ActionLink("删除", "Delete", new { id = item.Id }, new { @class = "btn btn-danger deleteBtn", @onclick = "return confirmDelete();" })
                        </td>
                    </tr>
                }
                @if (index == 0)
                {
                    <tr>
                        <td colspan="9" style="vertical-align:central;text-align:center;"> 暂无数据 </td>
                    </tr>

                }
            </tbody>
        </table>
    </div>
</div>
<script>
    function confirmDelete() {
        return confirm('你确定要删除吗？这将删除所有库存!');
    }
</script>

